/*
 Navicat Premium Data Transfer

 Source Server         : mariadb
 Source Server Type    : MariaDB
 Source Server Version : 100323
 Source Host           : localhost:3306
 Source Schema         : zcloud_community_service_v1

 Target Server Type    : MariaDB
 Target Server Version : 100323
 File Encoding         : 65001

 Date: 17/09/2025 15:32:50
*/

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for cs_community_menu
-- ----------------------------
DROP TABLE IF EXISTS `cs_community_menu`;
CREATE TABLE `cs_community_menu` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `publish` tinyint(1) NOT NULL COMMENT '是否发布',
  `description` tinytext DEFAULT NULL COMMENT '描述',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COMMENT='社区专栏';

-- ----------------------------
-- Records of cs_community_menu
-- ----------------------------
BEGIN;
INSERT INTO `cs_community_menu` VALUES (1, '公告', 1, '发布平台与活动公告');
INSERT INTO `cs_community_menu` VALUES (2, '学习', 1, '发布学习相关内容');
INSERT INTO `cs_community_menu` VALUES (3, '竞赛', 1, '发布竞赛相关内容');
INSERT INTO `cs_community_menu` VALUES (4, '资源', 1, '资源共享与公开');
COMMIT;

-- ----------------------------
-- Table structure for cs_community_post
-- ----------------------------
DROP TABLE IF EXISTS `cs_community_post`;
CREATE TABLE `cs_community_post` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `topic_id` bigint(20) NOT NULL COMMENT '话题ID',
  `title` varchar(255) NOT NULL,
  `content` longtext NOT NULL,
  `status` tinyint(5) NOT NULL COMMENT '0待审核 1下架 2上架 3隐藏(违规被ban)',
  `is_topped` tinyint(1) NOT NULL COMMENT '是否置顶',
  `is_selected` tinyint(1) NOT NULL COMMENT '是否精华贴',
  `is_official` tinyint(1) NOT NULL COMMENT '是否官方贴',
  `view_count` bigint(20) NOT NULL COMMENT '阅读量',
  `reason` mediumtext DEFAULT NULL COMMENT '被ban原因',
  `create_user` bigint(20) NOT NULL,
  `create_username` varchar(255) NOT NULL,
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='社区帖子';

-- ----------------------------
-- Records of cs_community_post
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for cs_community_post_approve
-- ----------------------------
DROP TABLE IF EXISTS `cs_community_post_approve`;
CREATE TABLE `cs_community_post_approve` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `post_id` bigint(20) NOT NULL,
  `create_user` bigint(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='帖子点赞映射表';

-- ----------------------------
-- Records of cs_community_post_approve
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for cs_community_post_comment
-- ----------------------------
DROP TABLE IF EXISTS `cs_community_post_comment`;
CREATE TABLE `cs_community_post_comment` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `post_id` bigint(20) NOT NULL COMMENT '帖子ID',
  `pid` bigint(20) DEFAULT NULL COMMENT '上一级评论ID',
  `content` longtext NOT NULL COMMENT '内容',
  `is_topped` tinyint(1) NOT NULL COMMENT '是否置顶',
  `create_user` bigint(20) NOT NULL,
  `create_username` varchar(255) NOT NULL,
  `reply_user` bigint(20) DEFAULT NULL COMMENT '回复用户',
  `reply_username` varchar(255) DEFAULT NULL COMMENT '回复用户ID',
  `created_at` datetime NOT NULL,
  `updated_at` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='帖子下评论';

-- ----------------------------
-- Records of cs_community_post_comment
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for cs_community_post_comment_approve
-- ----------------------------
DROP TABLE IF EXISTS `cs_community_post_comment_approve`;
CREATE TABLE `cs_community_post_comment_approve` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `post_id` bigint(20) NOT NULL COMMENT '帖子ID',
  `comment_id` bigint(20) NOT NULL COMMENT '评论ID',
  `create_user` bigint(20) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='评论点赞';

-- ----------------------------
-- Records of cs_community_post_comment_approve
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for cs_community_post_experiment_map
-- ----------------------------
DROP TABLE IF EXISTS `cs_community_post_experiment_map`;
CREATE TABLE `cs_community_post_experiment_map` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `post_id` bigint(20) NOT NULL,
  `experiment_id` bigint(20) NOT NULL,
  `experiment_name` varchar(255) NOT NULL,
  `course_resource_id` varchar(255) NOT NULL,
  `chapter_ref_id` varchar(255) NOT NULL COMMENT '章节ID',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='帖子实验映射表（求助）';

-- ----------------------------
-- Records of cs_community_post_experiment_map
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for cs_community_topic
-- ----------------------------
DROP TABLE IF EXISTS `cs_community_topic`;
CREATE TABLE `cs_community_topic` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT,
  `name` varchar(255) NOT NULL,
  `image_url` tinytext DEFAULT NULL,
  `description` mediumtext NOT NULL,
  `menu_id` bigint(20) NOT NULL,
  `type` tinyint(5) NOT NULL COMMENT '0审批后发布 1无需审批 2禁止发布',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=13 DEFAULT CHARSET=utf8mb4 COMMENT='社区话题';

-- ----------------------------
-- Records of cs_community_topic
-- ----------------------------
BEGIN;
INSERT INTO `cs_community_topic` VALUES (1, '站内公告', NULL, '发布站内公告，获取实时信息', 1, 2);
INSERT INTO `cs_community_topic` VALUES (2, '课程问答', NULL, '课程内学习、实验问答', 2, 1);
INSERT INTO `cs_community_topic` VALUES (3, '学习讨论', NULL, '分享学习知识，促进学习交流！', 2, 1);
INSERT INTO `cs_community_topic` VALUES (4, '技术分享', NULL, '分享你的学习心得、学习方式、问题解决思路', 2, 1);
INSERT INTO `cs_community_topic` VALUES (5, '常见问题', NULL, '官方发布的常见题及解决方法', 2, 2);
INSERT INTO `cs_community_topic` VALUES (6, '产品建议', NULL, '发表您对产品的看法与建议', 2, 1);
INSERT INTO `cs_community_topic` VALUES (7, '职业院校技能大赛', NULL, '发布职业院校技能大赛相关资讯与讨论', 3, 1);
INSERT INTO `cs_community_topic` VALUES (8, '职业技能大赛', NULL, '发布职业技能大赛相关资讯与讨论', 3, 1);
INSERT INTO `cs_community_topic` VALUES (9, '竞赛解题', NULL, '发布技能大赛相关解题思路', 3, 1);
INSERT INTO `cs_community_topic` VALUES (10, '资源共享', NULL, '欢迎分享相关学习、竞赛、教学、就业相关资源', 4, 1);
INSERT INTO `cs_community_topic` VALUES (11, '资源公开', NULL, '官方发布的相关资源公开', 4, 2);
INSERT INTO `cs_community_topic` VALUES (12, '活动公告', '', '发布活动相关公告', 1, 0);
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;
